 ///
 /// @file    associative_container5.cc
 /// @author  lemon(haohb13@gmail.com)
 /// @date    2016-03-08 15:53:34
 ///
 
#include <iostream>
#include <map>
#include <string>

using std::cout;
using std::endl;
using std::map;
using std::multimap;
using std::string;
using std::pair;

int main(void)
{
	pair<int, string> pairArr[2] = {
		pair<int, string>(1, "A"),
		pair<int, string>(2, "B")
	};
	
	map<int, string> mapIntStr(pairArr, pairArr + 2);

	pair<int, string> t(2, "X");
	map<int, string>::iterator mit = mapIntStr.begin();

	pair<map<int, string>::iterator, bool> 
		pairRet = mapIntStr.insert(t);

	if(pairRet.second)
	{
		cout << "数据插入成功" << endl;
		cout << pairRet.first->first << "-->"
			 << pairRet.first->second << endl;
	}
	else
	{
		cout << "map中已经包含关键字与t相同的元素:"
			 << pairRet.first->first << "-->"
			 << pairRet.first->second << endl;
	}
	cout << endl;
	
	multimap<int, string> mmapIntStr(pairArr, pairArr + 2);
	
	multimap<int, string>::iterator mmit;
	mmit = mmapIntStr.insert(t);
	cout << mmit->first << "-->"
		 << mmit->second << endl;


}

